/**
 * 
 */
package com.alphasystem.commerce.common.service;

import java.util.List;

import javax.persistence.EntityManager;

import com.alphasystem.commerce.common.ApplicationException;
import com.alphasystem.commerce.common.model.AbstractEntity;
import com.alphasystem.commerce.common.model.AbstractEntity_;
import com.alphasystem.commerce.common.service.sequence.SequenceService;
import com.alphasystem.commerce.common.valuelist.ValueListObject;

/**
 * @author sali
 * 
 */
public interface ServiceFacade<T extends AbstractEntity, M extends AbstractEntity_, V extends ValueListObject> {

	/**
	 * @return
	 * @throws ApplicationException
	 */
	public T create() throws ApplicationException;

	/**
	 * @param id
	 * @return
	 * @throws ApplicationException
	 */
	public T create(String id) throws ApplicationException;

	/**
	 * @return
	 */
	public List<T> findAll() throws ApplicationException;

	/**
	 * @param eager
	 * @return
	 * @throws ApplicationException
	 */
	public List<T> findAll(boolean eager) throws ApplicationException;

	/**
	 * @param eager
	 * @param from
	 * @param max
	 * @return
	 */
	public List<T> findAll(boolean eager, int from, int max)
			throws ApplicationException;

	/**
	 * @param from
	 * @param max
	 * @return
	 */
	public List<T> findAll(int from, int max) throws ApplicationException;

	/**
	 * @param id
	 * @return
	 */
	public T findById(String id) throws ApplicationException;

	/**
	 * @param id
	 * @return
	 */
	public T findById(String id, boolean eager) throws ApplicationException;

	/**
	 * @return
	 */
	public long getCount() throws ApplicationException;

	/**
	 * @return
	 */
	public EntityManager getEntityManager();

	/**
	 * @return
	 */
	public SequenceService getSequenceService();

	/**
	 * @return
	 * @throws ApplicationException
	 */
	public List<V> getValueList() throws ApplicationException;

	/**
	 * @param from
	 * @param max
	 * @return
	 * @throws ApplicationException
	 */
	public List<V> getValueList(int from, int max) throws ApplicationException;

	/**
	 * @param id
	 * @throws ApplicationException
	 */
	public void remove(String id) throws ApplicationException;

	/**
	 * @param entity
	 * @throws ApplicationException
	 */
	public void remove(T entity) throws ApplicationException;

	/**
	 * @param entity
	 * @throws ApplicationException
	 */
	public void save(T entity) throws ApplicationException;

	/**
	 * @param em
	 */
	public void setEntityManager(EntityManager em);

	/**
	 * @param sequence
	 */
	public void setSequenceService(SequenceService sequence);

	/**
	 * @param entity
	 * @return
	 * @throws ApplicationException
	 */
	public T update(T entity) throws ApplicationException;
}
